package com.longteng.testng.param;

import com.longteng.testng.MethodParam;
import jodd.paramo.MethodParameter;
import jodd.paramo.Paramo;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * Created by sky on 15-12-25
 */
public class MethodParams {

    public static MethodParam[] parse(Method method){
        MethodParam[] methodParams = new MethodParam[method.getParameterCount()];
        Parameter[] parameters = method.getParameters();
        MethodParameter[] methodParameters = Paramo.resolveParameters(method);
        for(int i=0;i<methodParameters.length;i++){
            MethodParam methodParam = new MethodParam(methodParameters[i].getName());
            methodParam.setParameter(parameters[i]);
            methodParams[i]=methodParam;
        }
        return methodParams;
    }
}
